package cn.masterj.springcloud.service;

import cn.masterj.springcloud.service.fallback.PaymentServiceFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * @author masterJ
 * @create 2020-04-10 19:46
 */
@Service
/**
 * 配上了fallback，这个类就对类里面的所有方法都启用了hystrix功能,直接使用fallback = PaymentServiceFallback.class，捕捉不到异常信息。
 * 如果要捕捉异常信息就得使用fallbackFactory = PaymentServiceFallbackFactory.class
 */
//@FeignClient(value = "CLOUD-PROVIDER-PAYMENT",fallback = PaymentServiceFallback.class)
@FeignClient(value = "CLOUD-PROVIDER-PAYMENT",fallbackFactory = PaymentServiceFallbackFactory.class)
public interface IPaymentService {

    @GetMapping("/payment/ok")
    String payment_ok();

    @GetMapping("/payment/timeout")
    String payment_timeout();

    @GetMapping("/payment/exception")
    String payment_exception();

    @GetMapping("/payment/circuit/{id}")
    String payment_circuit(@PathVariable("id") Long id);

}
